<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
body {background:url(page_bg.png);}
img{ border:none}
*{ margin:0; padding:0; font-size:14px; color:#333}

.c{
    padding:10px;
}
    
.b{
	border-bottom-left-radius:3px;
	border-bottom-right-radius:3px;
	border-top-left-radius:3px;
	border-top-right-radius:3px;
	border-width:1px;
	border-style:solid;
 	border-top-color:#dcdcdc;
 	border-right-color:#dcdcdc;
 	border-bottom-color:#dcdcdc;
	border-left-color:#dcdcdc;
	margin:5px auto 0;
    background-color:white;
    width:302px;
}
    
.b span {
    padding-right:15px;
}
    
.b .span_clear {
    padding:0;
}
    
.top-line {
	border:none;
	border-top:1px solid #dcdcdc;
}

.clearfix:after {clear:both; content:'';display: block;font-size: 0;line-height: 0;visibility: hidden; width: 0;height: 0;}
.clearfix {+display: inline-block;}
* html .clearfix {height: 1%;}

.fl{ float:left}
.fr{ float:right}
    
.wrap{word-break:break-all; width:280px;}

</style>
<script>
    
function verify_name()
{
    if (template_name.value.length == 0) {
        location.href='open:alert?请填写模版名称';
        return false;
    }
    
    if (template_name.value.length < 2 || template_name.value.length > 10) {
        location.href='open:alert?模版名称应在2-10个字内';
        return false;
    }
    
    return true;
}
   

function verify_number(obj) {
    
    if (obj.value.length == 0) {
        location.href='open:alert?请正确的填写运费数据';
        return false;
    }

    var reg = new RegExp("^[0-9]*$");
    if (!reg.test(obj.value)) {
        location.href='open:alert?运费数据请填写正整数';
        return false;
    }
    
    return true;
}
    
function tester() {
    
    var result = false;
    
    if (verify_name()) {
        result = true;
    }
    else {
        return false;
    }
    
    if (freight_method[0].checked) {
        result = false;
        
        if (verify_number(default_quantity) && verify_number(default_amount) && verify_number(exceed_quantity) && verify_number(exceed_amount)) {
            result = true;
        }
    }
    
    return result;
}

////////////////////////////////////
    
function unit_refresh() {
    var unit_strings = document.getElementsByName("unit_string");
    for (var i = 0; i < unit_strings.length; i++) {
        unit_strings[i].innerHTML = unit.value;
    }
}
    
function fillSelect(id,selectedValue){
    var obj=document.getElementById(id);
    for (var i=0; i < obj.length; i++) {
        if (selectedValue == obj.options[i].value) {
            obj.selectedIndex = i;
            break;
        }
    }
}
    
    function check_freight_method() {
        
        if (freight_method[0].checked) {
            default_freight.style.display = "block";
            area_freight.style.display = "block";
        }
        else {
            default_freight.style.display = "none";
            area_freight.style.display = "none";
        }
        
        //返回：true=买家承担运费，false=卖家承担运费。因此使用[0]的选中状态即可
        return freight_method[0].checked;
    }

function selectValueById(id){
    var obj=document.getElementById(id);
    var index=obj.selectedIndex;
    var val = obj.options[index].getAttribute("value");
        
    return val;
}
    
function checkboxesValue(val)
{
    var checkboxes = document.getElementsByName("freight_method");
    for(var i = 0; i < checkboxes.length; i++) {
        if(checkboxes[i].value == val){
            checkboxes[i].checked = true;
        }
    }
}

function freightList(index,provinces,city_num,default_quantity,default_amount,exceed_quantity,exceed_amount){
    var obj=document.getElementById("area_freight_list");
        
    var element = "<div class='top-line c' onClick=\"javascript:location.href='open:area_selectVC?"+index+"'\"><img class='fr' style='margin-top:10px' src='arrow-r.png'><div>" + provinces +"等<b>"+city_num +"</b>个区域<br>"+ default_quantity +"件内，"+ default_amount +"元；每增加" + exceed_quantity +"件， "+exceed_amount+"元</div></div>";
        
    obj.innerHTML += element;
        
//        var obj=document.getElementById("111");
//        obj.innerHTML = element;
}
</script>
</head>
<body>
<div id='param'></div>
<div class="b">
    <div class="c">
        <span>模版名称</span><input type='text' id='template_name' placeholder='2-12个字' style="height:25px; width:200px" onBlur="verify_name();">
    </div>
</div>
<div class="b">
    <div class="c">
        <span>是否包邮</span>
        <label><input type='radio' name='freight_method' id='freight_method' checked='checked' value='0' onClick="check_freight_method();">买家承担运费</label>
        <label><input type='radio' name='freight_method' id='freight_method' value='1' onClick="check_freight_method();">卖家承担运费</label>
    </div>
</div>

<div class="b" id="default_freight">
    <div class="c clearfix">
        <span style="float:left">默认运费</span>
        <div style="font-size:12px; color:#fd6c01; line-height:12px; width:210px; float:right;">除指定区域外，其余地区的运费采用“默认运费”</div>
    </div>
	<div class="top-line c" style="padding-left:80px">
        <input type='text' name='unit_value' id='default_quantity' size='5' onBlur="verify_number(this);">件内，
            <input type='text' name='unit_price' id='default_amount' size='5' onBlur="verify_number(this);">元
    </div>
	<div class="top-line c" style="padding-left:80px">
        每增加<input type='text' name='addition_unit_value' id='exceed_quantity' size='5' onBlur="verify_number(this);">件内，
            <input type='text' name='addition_unit_price' id='exceed_amount' size='5' onBlur="verify_number(this);">元
    </div>
    <div class="top-line c" style="padding-left:40px; color:gray">
        温馨提示：计价单位“件”以商品单位为准
    </div>
</div>

<div class="b" id="area_freight">
    <div class="c">
        <span>区域运费</span>
        <font>为指定区域设置运费</font>
        <input type='button' id='add_area_freight' onClick="javascript:location.href='open:area_selectVC'" value="添加" style="margin-left:20px">
    </div>
    <div id="area_freight_list">
            <!--
            <div class="top-line" onClick="javascript:location.href='open_xxxVC?33&' + unit.value;">
                上海，重庆，北京，重庆，等<b>100</b>个区域<br>
                1件内，50元，每增加1件，20元
                <img style='float:right' src='arrow-r.png'>
                    </div>
             -->
    </div>
</div>

<div class="b" onClick="javascript:location.href='open:delivery_address';">
    <div class="c">
        <span>发货地址</span>
        <span id="address_delivery_title"></span>
        <img style='float:right' src="arrow-r.png">
    </div>
    <div class="top-line c wrap" id="address_delivery">
  
    </div>
</div>
<div class="b" onClick="javascript:location.href='open:return_address';">
    <div class="c">
        <span>退货地址</span>
        <span id="address_return_title"></span>
        <img style='float:right' src="arrow-r.png">
    </div>
    <div class="top-line c wrap" id="address_return">
        
    </div>
</div>

<div style="width:302px; margin:20px auto 0" id="delete_button">
    <img src='button_3.png' width='302' height='42' onClick="javascript:location.href='delete:template';">
</div>
<div style="width:302px; margin:20px auto 0" id="default">
    <img src='button_2.png' width='302' height='42' onClick="javascript:location.href='set:default';">
</div>

<div style="padding-bottom:10px"></div>
</body>
</html>